package com.ht.medicaltreatment.view

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import com.blankj.utilcode.util.ToastUtils
import com.ht.medicaltreatment.R
import com.xgst.lib.utils.ScreenUtils
import kotlinx.android.synthetic.main.dialog_96_layout.*
import kotlinx.android.synthetic.main.dialog_remark_layout.*
import kotlinx.android.synthetic.main.dialog_replace_layout.*

class NinetySixDialog(context: Context) : Dialog(context, R.style.dialogStyle) {

    private lateinit var onAgain:() -> Unit
    private lateinit var onJump:() -> Unit

    init {
        val view =
            LayoutInflater.from(context).inflate(R.layout.dialog_96_layout, null, false)
        setContentView(view)
        val attributes = window!!.attributes
        attributes.width= ScreenUtils.dp2px(context,300)
        //attributes.height= ScreenUtils.dp2px(context,300)
        window!!.attributes = attributes
        setCancelable(true)
        btnAgain.setOnClickListener {
            onAgain()
            dismiss()
        }
        btnJump.setOnClickListener {
            onJump()
            dismiss()
        }

    }

    fun showDialog(message:String,onJump:()->Unit,onAgain:()->Unit){
        this@NinetySixDialog.onAgain = onAgain
        this@NinetySixDialog.onJump = onJump
        val sp = message.split(";")
        if(sp.size == 2){
            tvRealName.text = "应为: ${sp[0]}"
            tvCurrentName.text = "扫描到的: ${sp[1]}"
        }
        show()
    }

}